Skip to content

Deduplicate tag ingredient EmiStack lists#933

Open
embeddedt wants to merge 1 commit intoemilyploszaj:1.21from
embeddedt:tag-dedup
Open

Deduplicate tag ingredient EmiStack lists#933
embeddedt wants to merge 1 commit intoemilyploszaj:1.21from
embeddedt:tag-dedup

Conversation

@embeddedt
Copy link
Contributor

This will likely need some refinement before being merged; opening it now to collect feedback.

This PR implements deduplication of the underlying stack lists used by TagEmiIngredient after all recipes are constructed. Initial testing suggests it saves about 80MB of memory in Craftoria; gains should scale with packs containing larger tags that are used often. The TagEmiIngredient objects themselves are still duplicated, but their shallow size isn't the majority of memory usage from what I see.

@emilyploszaj
Copy link
Owner

Seems like a reasonable performance target, hashing the lists seems perhaps a bit wasteful though, surely ingredients could do lookups via tag key and then do comparison, or perhaps ignore all ingredients with mutated (chanced, remainder) elements

@embeddedt embeddedt force-pushed the tag-dedup branch 2 times, most recently from e7fdb00 to 2b42705 Compare May 15, 2025 00:05
@embeddedt
Copy link
Contributor Author

I tried this and it's unfortunately a weaker optimization. Hashing the lists is more powerful as it can correctly deduplicate cases where many tag ingredients have mutated the ingredients in the exact same way (e.g. in Monifactory, there are a bunch of wrench tag ingredients where all the inner stacks have remainders with the wrench damaged by one more unit). The lookup approach barely saves anything in Monifactory, by comparison.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants